home *** CD-ROM | disk | FTP | other *** search
Text File | 1997-05-22 | 2.9 KB | 190 lines | [TEXT/CWIE] |
- // Event handling code
-
- // Application-specific headers
- #include "app.h"
-
- // API headers
- #include "qtvrsupp.h"
-
- // System headers
- #include <AppleEvents.h>
- #include <movies.h>
-
-
- /////
- //
- // Local data structures
- //
- /////
-
-
- /////
- //
- // Local Prototypes
- //
- /////
-
- // xxx
- void DoMouseDown(EventRecord *theEvent); // Handle MouseDown events
- void DoUpdate(EventRecord *theEvent); // Handle Update events
- void DoMenuChoice(long menuResult); // Handle Menu selections
- void DoKeypress(char CharCode, char KeyCode); // Handle Keypresses
-
- void DoNull();
-
-
- /////
- //
- // The main event-processing loop
- //
- /////
-
- void EventLoop()
- {
- char charCode, keyCode;
- EventRecord theEvent;
-
- while (g.Done == false)
- {
- WaitNextEvent(everyEvent, &theEvent, nil, nil);
-
- if (!CheckMovieControllers(&theEvent))
- {
- switch (theEvent.what)
- {
- case kHighLevelEvent:
- AEProcessAppleEvent(&theEvent);
- break;
- case nullEvent:
- DoNull();
- break;
- case mouseDown:
- DoMouseDown(&theEvent);
- break;
- case keyDown:
- case autoKey:
- charCode = theEvent.message & charCodeMask;
- keyCode = (theEvent.message & keyCodeMask) >> 8;
- if ((theEvent.modifiers & cmdKey) != 0) {
- DoMenuSetup();
- DoMenuChoice(MenuKey(charCode));
- } else
- DoKeypress(charCode, keyCode);
- break;
- case activateEvt:
- break;
- case updateEvt:
- DoUpdate(&theEvent);
- break;
- }
- }
-
- }
-
- }
-
-
- /////
- //
- // Handle MouseDown events
- //
- /////
-
- void DoMouseDown(EventRecord *theEvent)
- {
- WindowPtr whichWindow;
- short int thePart;
- long int menuChoice;
-
- thePart = FindWindow(theEvent->where, &whichWindow);
-
-
- switch (thePart)
- {
- case inMenuBar:
- DoMenuSetup();
- menuChoice = MenuSelect(theEvent->where);
- DoMenuChoice(menuChoice);
- break;
- case inSysWindow:
- SystemClick(theEvent, whichWindow);
- break;
- case inDrag:
- SelectWindow(whichWindow);
- DragWindow(whichWindow, theEvent->where, &qd.screenBits.bounds);
- break;
- case inGrow:
- break;
- case inZoomIn:
- case inZoomOut:
-
- break;
- case inGoAway:
- if(TrackGoAway(whichWindow, theEvent->where))
- CloseMovieByWindow(whichWindow);
- break;
- case inContent:
- if (whichWindow != FrontWindow())
- SelectWindow(whichWindow);
- break;
-
- }
- }
-
-
- /////
- //
- // Handle Keypresses
- //
- /////
-
- void DoKeypress(char CharCode, char KeyCode)
- {
- Boolean CharHandled = true;
-
- // If <modifier(s)>
- switch(CharCode) {
- // case <case>:
- default:
- CharHandled = false;
- break;
- }
-
- if (!CharHandled)
- CharHandled = mQTVRDoKeypress(CharCode, KeyCode);
-
- // etc...
- // if (!CharHandled)
- // CharHandled = mQTVRDoKeypress(CharCode, KeyCode, EventType);
-
- }
-
- /////
- //
- // Handle Update events
- //
- /////
-
- void DoUpdate(EventRecord *theEvent)
- {
-
- CWindowPtr whichWindow;
-
- whichWindow = (CWindowPtr)theEvent->message;
- SetGWorld(whichWindow, nil);
- BeginUpdate((WindowPtr)whichWindow);
-
- EndUpdate((WindowPtr)whichWindow);
- }
-
-
- void DoNull()
- {
- MyMoviesTask(FrontWindow());
- }
-
-
-
-
-
-